package com.zztl.infiniteBand.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zztl.infiniteBand.R
import com.zztl.infiniteBand.model.CountryCodeBean
import com.zztl.infiniteBand.util.UiUtils

/**
 * @desc
 * @auth ${user}
 * @time 2018/6/13  20:02
 */
class CountryCodeAdapter(layoutResId: Int, data: List<CountryCodeBean.DataBean>) : BaseQuickAdapter<CountryCodeBean.DataBean, BaseViewHolder>(layoutResId, data) {

    override fun convert(helper: BaseViewHolder, item: CountryCodeBean.DataBean) {
        helper.setText(R.id.tv_country_name, item.countryName)
        helper.setText(R.id.tv_country_code, "+${item.countryCode}")
        if (data.indexOf(item) == 0) {
            helper.setGone(R.id.firstLetter, true)
//            helper.setText(R.id.firstLetter, UiUtils.getString(R.string.���ù��ҵ���))
        } else if (data.indexOf(item) == 6) {
            helper.setGone(R.id.firstLetter, true)
            helper.setText(R.id.firstLetter, item.firstLetter)
        } else {
            val bean = data[data.indexOf(item) - 1]
            if (bean.firstLetter.equals(item.firstLetter, true)) {
                helper.setGone(R.id.firstLetter, false)
            } else {
                helper.setGone(R.id.firstLetter, true)
                helper.setText(R.id.firstLetter, item.firstLetter)
            }
        }
    }


}
